package com.yunyi.system.common;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author LiLing
 * @Date 2023/5/26 上午 8:48
 * @ClassName: R
 * 统一返回类型
 * @Description: TODO
 * @Version 1.0
 */

public class R {

    //代码
    private int code = REnum.succes.code ;
    //提示
    private String message = REnum.succes.message ;
    //数据
    Map<String,Object> data = new HashMap();

    public int getCode() {
        return code;
    }

    public R setCode(int code) {
        this.code = code;
        return this ;
    }

    public String getMessage() {
        return message;
    }

    public R setMessage(String message) {
        this.message = message;
        return this ;
    }

    public Map<String, Object> getData() {
        return data;
    }

    public void setData(Map<String, Object> data) {
        this.data = data;
    }

    /**
     * 追加数据
     * @param key
     * @param obj
     */
    public R addDate(String key , Object obj){
        this.data.put(key,obj) ;
        return this; //链式调用
    }

    @Override
    public String toString() {
        return "R{" +
                "code=" + code +
                ", message='" + message + '\'' +
                ", data=" + data +
                '}';
    }
}
